package gui.menu.edit;

import data.DataVector;
import gui.commands.CommandManager;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.RichTooltip;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * User: Szymon Kudzia
 * Date: 10.05.13
 * Time: 14:17
 */
public class NewItem extends JCommandButton implements ActionListener {

	public NewItem() {
		super(ImageWrapperResizableIcon.getIcon(
				ClassLoader.getSystemClassLoader().getResource("icons/new.png"),
				new Dimension(16, 16))
		);

		this.setActionRichTooltip(new RichTooltip("New project", "Create a new blank project"));


		addActionListener(this);
	}


	public void actionPerformed(ActionEvent e) {
		if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
				"This operation cannot be undone, any unsaved changes will be lost. Do you want create new project?")) {

			CommandManager.getInstance().clearHistory();
			DataVector.getInstance().clear();
		}
	}
}
